// import NodeRSA from "node-rsa";
import NodeRSA from 'jsencrypt'
import {config} from "@/config";
import {VagueOject} from "@/types/common";

const rsa = new NodeRSA()
rsa.setPublicKey(config.rsaPublicKey);

export const PublicKeyEncryption = (text: VagueOject): string => {
    return <string>rsa.encrypt(JSON.stringify(text))
}

export const PublicKeyDecrypt = (text: string) => {
    console.log("text: ", rsa.decrypt(text));
    // return JSON.parse(<string>rsa.decrypt(text))
}